# name = "中午吃什么饭了"
#
# # 索引
# print(name[0])  # 第一个字符
# print(name[-1])  # 最后一个字符
# print(len(name))  # 长度
# print(name[len(name) // 2])  # 取中间，整除
#
# print("----------------------------------------")
# # 切片
# print(name[:3])     # 前三个，简写
# print(name[-3:])     # 后三个，简写
# print(name[::-1])     # 倒序输出
# print(name[::1])     # 正序输出

# highs = []
# while True:
#     height = input("请输入身高：")
#     if height == "":
#         for i in range(len(highs) - 1, -1, -1):
#             print(highs[i])
#         print("----------------------")
#         print(max(highs))
#         print(min(highs))
#         print(sum(highs) / len(highs))
#         break
#     else:
#         highs.append(int(height))

# list1 = [55, 66, 99, 54, 33, 98, 15, 22, 78]
# for i in range(len(list1)):     # 排序
#     for j in range(i, len(list1)):
#         if list1[i] > list1[j]:
#             temp = list1[j]
#             list1[j] = list1[i]
#             list1[i] = temp
# for i in range(len(list1)):
#     print(list1[i])

# import copy
#
# list2 = list1[::]  # 切片
# list3 = list1.copy()  # 浅拷贝 == 切片
# list4 = copy.deepcopy(list1)  # 深拷贝

# list1 = [55, 66, 99, 54, 33, 98, 15, 22, 78]
# # 倒序删除，防止漏删、下标越界等问题
# for i in range(len(list1) - 1, -1, -1):
#     if list1[i] < 50:
#         list1.remove(list1[i])

# list2 = [item for item in list1]
# list2 = [item for item in list1 if item > 20]
#

# # 生成1-50内，只能被3 / 5 整除的数
# list4 = [i for i in range(1, 51) if i % 3 == 0 or i % 5 == 0]
# # 生成5-20内数的三次方
# list5 = [i ** 3 for i in range(5, 21)]

while True:
    month = int(input("请输入月："))
    day = int(input("请输入日："))
    monthday = 0
    runYear = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
    # for i in range(month - 1):
    #     monthday += runYear[i]
    # answer = monthday + day
    # print(answer)

    answe = sum(runYear[:month - 1])
    answe += monthday + day
    print(answe)
